<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateScheduleInspectionPivotTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('schedule_inspection_pivot', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('schedule_id')->index()->comment('排班ID');
            $table->unsignedInteger('line_id')->index()->comment('线路ID');
            $table->unsignedInteger('user_id')->index()->comment('用户ID');
            $table->date('date')->index()->comment('日期');
            $table->unique(['schedule_id', 'date']);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('schedule_inspection_pivot');
    }
}
